<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('专辑推荐')" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="album-form">
				    <input type="hidden" id="albumIds" name="albumIds" th:value="${albumIds}">
					<div class="select-list">
						<ul>
							<li>
								项目名称：<input type="text" name="name"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var prefix = ctx + "media";
		$(function() {
			var options = {
		        url: prefix + "/item/noRecommendList/" + $("#albumIds").val(),
				showSearch: false,
				showRefresh: false,
				showToggle: false,
				showColumns: false,
				clickToSelect: true,
		        columns: [{
		            checkbox: true
		        },
		        {
		            field: 'itemId',
		            title: '项目id',
		            visible: false
		        },
		        {
		            field: 'name',
		            title: '项目名称',
		            sortable: true
		        }]
		    };
		    $.table.init(options);
		});

		/* 批量推荐-选择项目-提交 */
		function submitHandler() {
			var rows = $.table.selectColumns("itemId");
			if (rows.length == 0) {
				$.modal.alertWarning("请至少选择一个项目");
				return;
			}
			var data = {"albumIds": $("#albumIds").val(), "itemIds": rows.join()};
			$.operate.save(prefix + "/album/recommend", data);
		}
	</script>
</body>
</html>